package controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jfinal.core.paragetter.Para;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

import db.area;
import db.art;
import db.article;
import db.build;
import db.model;
import db.report;
import utils.Graph;
import utils.IResult;
import utils.OptionItem;

import com.jfinal.aop.Before;
import utils.UserInterceptor;

//鐢ㄦ埛鍔熻兘鎺ュ彛锛岀洰鍓嶇湅锛屼技涔庝笓涓氬拰闈炰笓涓氱敤鎴凤紝涓嶇敤鍚庡彴鍒ゆ柇锛屽墠绔垽鏂氨鍙互锛岄兘缁熶竴鐢ㄨ繖涓帴鍙ｅ氨琛�

//涓存椂娉ㄩ噴鎷︽埅鍣�
@Before(UserInterceptor.class)
public class UserController  extends RoleController{
	public UserController(){
		this.setRole(RoleController.PROUSER);
	}
	
	// 获取建筑列表
	public void getbuildlist() {
		//寰楀埌鏂囦繚鍗曚綅涓嬬殑鍏ㄩ儴鏂囦繚椤圭洰
		List<build> list = build.dao.find("select * from build");
		renderJson(IResult.ok(list));
	}	
//	获取建筑
	public void getbuild() {
		String buildid  =  getPara("buildid");
		build item = build.dao.findById(buildid);
		if(item != null) {
			renderJson(IResult.ok(item));
		}else {
			renderJson(IResult.fail("鏌ユ壘璁板綍澶辫触銆�"));
		}
	}
	
	// 获取区域列表
	public void getarealist() {
		String buildid  =  getPara("buildid");
		List<area> list = area.dao.find("select * from area where buildid=?",buildid);
		renderJson(IResult.ok(list));
	}
	
	// 获取区域的构件列表
	public void getmodellist(@Para("areaid")String areaid) {
		List<model> list = model.dao.find("select * from model where areaid = ?",areaid);
		renderJson(IResult.ok(list));
	}
//	获取建筑下的全部构件
	public void getbuildmodel(@Para("buildid")String buildid) {
		List<Record> listinfo = Db.find("select model.id, model.name, model.buildid, model.areaid,model.collecttime,model.path,model.memo,build.name as buildname,area.name as areaname from model "
				+ "left join (select build.id ,build.name from build) build on model.buildid=build.id "
				+ "left join (select area.id, area.name from area) area on model.areaid=area.id where model.buildid = ?",buildid);
		renderJson(IResult.ok(listinfo));
	}
	
//	获得建筑下的全部彩画
	public void getbuildart(@Para("buildid")String buildid) {
		List<Record> listinfo = Db.find("select art.id,art.name,art.buildid,art.areaid,art.modelid,art.width,art.height,art.year, art.artstyle,art.childstyle,art.content,art.collecor,art.collecttime,art.path,"
				+ "art.cx,art.cy,art.cz,art.ux,art.uy,art.uz,art.ax,art.ay,art.az,build.name as buildname,area.name as areaname, model.name as modelname from art "
				+ "left join (select build.id ,build.name from build) build on art.buildid=build.id "
				+ "left join (select area.id, area.name from area) area on art.areaid=area.id "
				+ "left join (select model.id, model.name from model) model on art.modelid=model.id where art.buildid = ?",buildid);
		renderJson(IResult.ok(listinfo));
	}
	
//	获取构建
	public void getmodel() {
		String modelid  =  getPara("modelid");
		model item = model.dao.findById(modelid);
		if(item != null) {
			renderJson(IResult.ok(item));
		}else {
			renderJson(IResult.fail("鏌ユ壘璁板綍澶辫触銆�"));
		}
	}
//	所有彩画
	public void getallart() {
		List<Record> listinfo = Db.find("select art.id,art.name,art.buildid,art.areaid,art.modelid,art.width,art.height,art.year, art.artstyle,art.childstyle,art.content,art.collecor,art.collecttime,art.path,"
				+ "art.cx,art.cy,art.cz,art.ux,art.uy,art.uz,art.ax,art.ay,art.az,build.name as buildname,area.name as areaname, model.name as modelname from art "
				+ "left join (select build.id ,build.name from build) build on art.buildid=build.id "
				+ "left join (select area.id, area.name from area) area on art.areaid=area.id "
				+ "left join (select model.id, model.name from model) model on art.modelid=model.id");
		renderJson(IResult.ok(listinfo));
	}
	
	// 获取彩画列表
	public void getartlist(@Para("modelid")String modelid) {
		List<art> list = art.dao.find("select * from art where modelid = ?",modelid);
		renderJson(IResult.ok(list));
	}
	// 获取建筑页相机信息的接口
	public void getartlist2(@Para("buildid") String buildid) {
	    // 查询 art 表和 build 表的数据
	    String sql = "SELECT a.*, b.name AS buildname FROM art a " +
	                 "LEFT JOIN build b ON a.buildid = b.id " +
	                 "WHERE a.buildid = ?";
	    List<Record> list = Db.find(sql, buildid);

	    // 返回查询结果
	    renderJson(IResult.ok(list));
	}

//	获取彩画
	public void getart() {
		String artid  =  getPara("artid");
		art item = art.dao.findById(artid);
		if(item != null) {
			renderJson(IResult.ok(item));
		}else {
			renderJson(IResult.fail("鏌ユ壘璁板綍澶辫触銆�"));
		}
	}	

	
	// 获取彩画选项 三级联动
	public void getareaoptions() {
		List<OptionItem> list = new ArrayList<OptionItem>() ;
		List<Record> listbuild = Db.find("select id as value,name as label from build");
		List<Record> listarea = Db.find("select id as value,name as label, buildid as pid from area");

		for(Record itemunit : listbuild) {
			OptionItem unitdata = new OptionItem(itemunit.getStr("value"),itemunit.getStr("label"));
			for(Record itemproject : listarea) {
				if(itemunit.getStr("value").equals(itemproject.getStr("pid"))) {
					OptionItem projectdata = new OptionItem(itemproject.getStr("value"),itemproject.getStr("label"));
					unitdata.getChildren().add(projectdata);
				}
			}
			list.add(unitdata);
		}
		
		renderJson(IResult.ok(list));
	}
	// 获取区域点位
	public void getpartoptions() {
		List<OptionItem> list = new ArrayList<OptionItem>() ;
		List<Record> listbuild = Db.find("select id as value,name as label from build");
		List<Record> listarea = Db.find("select id as value,name as label, buildid as pid from area");
		List<Record> listmodel = Db.find("select id as value,name as label, areaid as pid from model");

		for(Record itemunit : listbuild) {
			OptionItem unitdata = new OptionItem(itemunit.getStr("value"),itemunit.getStr("label"));
			for(Record itemproject : listarea) {
				if(itemunit.getStr("value").equals(itemproject.getStr("pid"))) {
					OptionItem projectdata = new OptionItem(itemproject.getStr("value"),itemproject.getStr("label"));
					for(Record itembuild : listmodel) {
						if(itemproject.getStr("value").equals(itembuild.getStr("pid"))) {
							OptionItem builddata = new OptionItem(itembuild.getStr("value"),itembuild.getStr("label"));
							projectdata.getChildren().add(builddata);
						}
					}
					unitdata.getChildren().add(projectdata);
				}
			}
			list.add(unitdata);
		}
		
		renderJson(IResult.ok(list));
	}
	
	// 获取文献列表
	public void getarticlelist() {
		List<article> list = article.dao.findAll();
		renderJson(IResult.ok(list));
	}
//	获取文献
	public void getarticle() {
		String articleid  =  getPara("articleid");
		article item = article.dao.findById(articleid);
		if(item != null) {
			renderJson(IResult.ok(item));
		}else {
			renderJson(IResult.fail("鏌ユ壘璁板綍澶辫触銆�"));
		}
	}
	
	// 获取报告列表
	public void getreportlist() {
		List<report> list = report.dao.findAll();
		renderJson(IResult.ok(list));
	}
	// 获取报告
	public void getreport() {
		String reportid  =  getPara("reportid");
		report item = report.dao.findById(reportid);
		if(item != null) {
			renderJson(IResult.ok(item));
		}else {
			renderJson(IResult.fail("错误"));
		}
	}
	
	//获取部分树
		public void getparttree() {
			String buildid  =  getPara("buildid");
			List<OptionItem> list = new ArrayList<OptionItem>() ;

			List<Record> listarea = Db.find("select id as value,name as label, buildid as pid from area where buildid=?",buildid);
			List<Record> listmodel = Db.find("select id as value,name as label, areaid as pid from model");

			for(Record itemproject : listarea) {
				OptionItem projectdata = new OptionItem(itemproject.getStr("value"),itemproject.getStr("label"));
				for(Record itembuild : listmodel) {
					if(itemproject.getStr("value").equals(itembuild.getStr("pid"))) {
						OptionItem builddata = new OptionItem(itembuild.getStr("value"),itembuild.getStr("label"));
						projectdata.getChildren().add(builddata);
					}
				}
				list.add(projectdata);
			}
			renderJson(IResult.ok(list));
		}
		
//	获取登录人数
		public void gettotallogin() {
			List<Record> list = Db.find("select COUNT(id) as value from log where action='登入系统'");
			renderJson(IResult.ok(list));
		}
		
		
		// 20240709 update **********************************************
		
//		获取所有建筑数量并对应该建筑下的彩画数量，用于知识图谱页统计图
		public void getAllBuildNum() {
		    // 获取所有建筑的名称和 id
		    List<Record> buildList = Db.find("select id, name from build");

		    // 创建一个列表来存储每个建筑及其彩画数量
		    List<Record> resultList = new ArrayList<>();

		    // 遍历所有建筑，查询每个建筑下的彩画数量
		    for (Record build : buildList) {
		        int buildId = build.getInt("id");
		        String buildName = build.getStr("name");

		        // 查询当前建筑下的彩画数量
		        Record artCount = Db.findFirst("select COUNT(*) as artCount from art where buildid = ?", buildId);

		        // 创建一个新的记录，将建筑名称及其彩画数量添加到结果列表中
		        Record result = new Record();
		        result.set("name", buildName);
		        result.set("artCount", artCount.getLong("artCount"));

		        resultList.add(result);
		    }

		    // 返回结果列表
		    renderJson(IResult.ok(resultList));
		}
		
//		获取建筑下的构件数量
		public void getAllModelNum() {
		    // 查询所有建筑的 id 和名称
		    List<Record> buildList = Db.find("select id, name from build");

		    // 创建一个列表来存储每个建筑及其构件数量
		    List<Record> resultList = new ArrayList<>();

		    // 遍历所有建筑，查询每个建筑下的构件数量
		    for (Record build : buildList) {
		        int buildId = build.getInt("id");
		        String buildName = build.getStr("name");

		        // 查询当前建筑下的构件数量
		        Record modelCount = Db.findFirst("select COUNT(*) as modelCount from model where buildid = ?", buildId);

		        // 创建一个新的记录，将建筑名称及其构件数量添加到结果列表中
		        Record result = new Record();
		        result.set("name", buildName);
		        result.set("modelCount", modelCount.getLong("modelCount"));

		        resultList.add(result);
		    }

		    // 返回结果列表
		    renderJson(IResult.ok(resultList));
		}
		
//		获取建筑下的区域数量和名称
		public void getAllAreaNum() {
			// 查询所有建筑的 id 和 name
		    List<Record> buildList = Db.find("select id, name from build");

		    // 创建一个列表来存储每个建筑及其区域信息
		    List<Record> resultList = new ArrayList<>();

		    // 遍历所有建筑，查询每个建筑下的区域数量和名称
		    for (Record build : buildList) {
		        int buildId = build.getInt("id");
		        String buildName = build.getStr("name");

		        // 查询当前建筑下的所有区域
		        List<Record> areaList = Db.find("select name from area where buildid = ?", buildId);
		        
		        // 创建一个新的记录，将建筑名称及其区域数量和名称添加到结果列表中
		        Record result = new Record();
		        result.set("buildName", buildName);
		        result.set("areaCount", areaList.size());
		        result.set("areaNames", areaList);

		        resultList.add(result);
		    }

		    // 返回结果列表
		    renderJson(IResult.ok(resultList));
		}
		
		


		
		

		
		// 获取知识图谱的关系结构  优化结构 分别查询
//		public void getgraph() {
//			// 初始化图形结构
//		    Graph g = new Graph();
//		    g.AddNode("恭王府","0","建筑群");
//
//		    // 查询所有建筑数据 并添加节点和链接
//		    List<build> list = build.dao.findAll();
//		    for(build item : list) {
//		        String buildId = item.getStr("id");
//		        g.AddNode(item.getStr("name"), buildId, "建筑");
//		        g.AddLink("0", buildId);
//
//		        // 查询该建筑下的所有区域数据 并添加节点和链接
//		        List<area> listarea = area.dao.find("SELECT * FROM area WHERE buildid = ?", buildId);
//		        for (area itemarea : listarea) {
//		            String areaId = itemarea.getStr("id");
//		            g.AddNode(itemarea.getStr("name"), areaId, "区域");
//		            g.AddLink(buildId, areaId);
//
//		            // 查询该区域下的所有构件数据 并添加节点和链接
//		            List<model> listmodel = model.dao.find("SELECT * FROM model WHERE areaid = ?", areaId);
//		            for (model itemmodel : listmodel) {
//		                String modelId = itemmodel.getStr("id");
//		                g.AddNode(itemmodel.getStr("name"), modelId, "构件");
//		                g.AddLink(areaId, modelId);
//
//		                // 查询该构件下的所有彩画数据 并添加节点和链接
//		                List<art> listart = art.dao.find("SELECT * FROM art WHERE modelid = ?", modelId);
//		                for (art itemart : listart) {
//		                    String artId = itemart.getStr("id");
//		                    g.AddNode(itemart.getStr("name"), artId, "彩画");
//		                    g.AddLink(modelId, artId);
//		                }
//		            }
//		        }
//
//		        // 查询该建筑下的所有彩画数据（如果彩画数据是直接关联到建筑的）
//		        List<art> listart = art.dao.find("SELECT * FROM art WHERE buildid = ?", buildId);
//		        for (art itemart : listart) {
//		            String artId = itemart.getStr("id");
//		            g.AddNode(itemart.getStr("name"), artId, "彩画");
//		            g.AddLink(buildId, artId);
//		        }
//		    }
//
//		    renderJson(IResult.ok(g));
//		}
		
		
		
		// 20240715 update**********************************
		// 获取art表中彩画分类，每类的彩画数量 
		public void getArtStyleCount() {
	        // 定义四大类的名称
	        String[] artStyles = {"和玺彩画", "旋子彩画", "苏式彩画", "海墁彩画"};

	        // 创建一个列表来存储每种艺术风格及其数量
	        List<Record> resultList = new ArrayList<>();

	        // 遍历四大类，查询每种艺术风格的数量
	        for (String artStyle : artStyles) {
	            // 查询当前艺术风格的数量
	            Record artStyleCount = Db.findFirst("select COUNT(*) as count from art where artstyle = ?", artStyle);

	            // 创建一个新的记录，将艺术风格名称及其数量添加到结果列表中
	            Record result = new Record();
	            result.set("artStyle", artStyle);
	            result.set("count", artStyleCount.getLong("count"));

	            resultList.add(result);
	        }

	        // 返回结果列表
	        renderJson(IResult.ok(resultList));
	    }
		
		
		
		// 获取知识图谱的关系结构2
		public void getgraph2() {
		    // 初始化图形结构
		    Graph g = new Graph();
		    g.AddNode("恭王府", "0", "建筑群", 0, 0); // 添加 level 和 childrenNum

		    // 查询所有建筑数据 并添加节点和边
		    List<build> listBuild = build.dao.findAll();
		    for (build itemBuild : listBuild) {
		        String buildId = itemBuild.getStr("id");
		        g.AddNode(itemBuild.getStr("name"), buildId, "建筑", 1, 0); // 建筑的 childrenNum 固定为 0
		        g.AddEdge("0", buildId); // 使用 AddEdge 替代 AddLink
		    }

		    // 查询所有区域数据 并添加节点和边
		    List<area> listArea = area.dao.findAll();
		    for (area itemArea : listArea) {
		        String areaId = itemArea.getStr("id");
		        String buildId = itemArea.getStr("buildid");
		        g.AddNode(itemArea.getStr("name"), areaId, "区域", 2, 0); // 区域的 childrenNum 固定为 0
		        g.AddEdge(buildId, areaId); // 使用 AddEdge 替代 AddLink
		    }

		    // 查询所有构件数据 并添加节点和边
//		    List<model> listModel = model.dao.findAll();
//		    for (model itemModel : listModel) {
//		        String modelId = itemModel.getStr("id");
//		        String areaId = itemModel.getStr("areaid");
//		        g.AddNode(itemModel.getStr("name"), modelId, "构件", 3, 0); // 构件的 childrenNum 固定为 0
//		        g.AddEdge(areaId, modelId); // 使用 AddEdge 替代 AddLink
////		        System.out.println("model: " + listModel); // 这里可以打印出来所有的彩画数据
//		    }
//
//		    // 查询所有art彩画数据 并添加节点和边
//		    List<art> listArt = art.dao.findAll();
//		    System.out.println("arts: " + listArt); // 这里可以打印出来所有的彩画数据
//		    for (art itemArt : listArt) {
//		        String artId = itemArt.getStr("id");
//		        String modelId = itemArt.getStr("modelid");
//		        g.AddNode(itemArt.getStr("name"), artId, "彩画", 4, 0); // 彩画的 childrenNum 固定为 0
//		        g.AddEdge(modelId, artId); // 使用 AddEdge 替代 AddLink
//		        System.out.println("Added Node: " + itemArt.getStr("name")); // 这里可以正确打印
//		    }

		    // 返回 nodes 和 edges 两个数组
		    Map<String, Object> result = new HashMap<>();
		    result.put("nodes", g.getNodes());
		    result.put("edges", g.getEdges());
		    System.out.println("Result: " + result);
		    renderJson(IResult.ok(result));
		}
		 
		// update 20240724 by FR13NDS
//		public void getgraph2() {
//	    // 初始化图形结构
//	    Graph g = new Graph();
//	    g.AddNode("恭王府", "0", "建筑群", 0, 0); // 添加 level 和 childrenNum
//
//	    // 查询所有建筑数据 并添加节点和边
//	    List<build> listBuild = build.dao.findAll();
//	    for (build itemBuild : listBuild) {
//	        String buildId = itemBuild.getStr("id");
//	        g.AddNode(itemBuild.getStr("name"), buildId, "建筑", 1, 0); // 建筑的 childrenNum 固定为 0
//	        g.AddEdge("0", buildId); // 使用 AddEdge 替代 AddLink
//	    }
//
//	    // 查询所有区域数据 并添加节点和边
//	    List<area> listArea = area.dao.findAll();
//	    for (area itemArea : listArea) {
//	        String areaId = itemArea.getStr("id");
//	        String buildId = itemArea.getStr("buildid");
//	        g.AddNode(itemArea.getStr("name"), areaId, "区域", 2, 0); // 区域的 childrenNum 固定为 0
//	        g.AddEdge(buildId, areaId); // 使用 AddEdge 替代 AddLink
//	    }
//
//	   
//
//
//	    // 返回 nodes 和 edges 两个数组
//	    Map<String, Object> result = new HashMap<>();
//	    result.put("nodes", g.getNodes());
//	    result.put("edges", g.getEdges());
//	    System.out.println("Result: " + result);
//	    renderJson(IResult.ok(result));
//	}




		// 获取看板页第二张图的isMark=1的数据
		public void getIsMark() {
		    try {
		        // 查询所有建筑
		        List<build> buildList = build.dao.find("select * from build");

		        // 查询所有 isMark 为 1 的 art 记录，并按 buildid 分组计数
		        List<Record> artList = Db.find("SELECT buildid, COUNT(*) as count FROM art WHERE isMark = 1 GROUP BY buildid");
		        Map<Integer, Integer> artCountMap = new HashMap<>();
		        for (Record art : artList) {
		            int buildid = art.getInt("buildid");
		            int count = art.getInt("count");
		            artCountMap.put(buildid, count);
		        }

		        // 构建带有 buildid, name 和数量的结果列表
		        List<Record> resultList = new ArrayList<>();
		        for (build b : buildList) {
		            int buildid = b.getInt("id");
		            String name = b.getStr("name");
		            int count = artCountMap.getOrDefault(buildid, 0);

		            Record result = new Record();
		            result.set("buildid", buildid); // 添加 buildid
		            result.set("name", name);
		            result.set("count", count);
		            resultList.add(result);
		        }

		        // 返回前 10 条数据
		        renderJson(IResult.ok(resultList.subList(0, Math.min(10, resultList.size()))));
		    } catch (Exception e) {
		        e.printStackTrace();
		        renderJson(IResult.fail("查询过程中发生错误。"));
		    }
		}

		
		// 获取看板页第二张图的marks=2的数据
		public void getMarks() {
		    List<Record> records = Db.find("SELECT artstyle, COUNT(*) AS count FROM art WHERE marks = 2 GROUP BY artstyle");
		    
		    // 创建一个Map以存储artstyle和对应的数量
		    Map<String, Integer> resultMap = new HashMap<>();
		    
		    // 获取查询结果并填充到Map中
		    for (Record record : records) {
		        resultMap.put(record.getStr("artstyle"), record.getInt("count"));
		    }
		    
		    // 获取所有可能的artstyle
		    List<String> allArtStyles = getAllArtStyles();
		    
		    // 创建最终结果列表
		    List<Map<String, Object>> result = new ArrayList<>();
		    
		    for (String style : allArtStyles) {
		        Map<String, Object> map = new HashMap<>();
		        map.put("name", style);
		        map.put("count", resultMap.getOrDefault(style, 0)); // 如果没有数据，使用0
		        result.add(map);
		    }

		    renderJson(IResult.ok(result));
		}

		private List<String> getAllArtStyles() {
		    return List.of("苏式彩画", "旋子彩画", "和玺彩画", "海堤彩画"); // 这里填充所有可能的artstyle
		}
		
		
		// 获取采样信息按钮的数据
		public void getPoint() {
		    try {
		        // 查询 art 表中所需的列
		        List<Record> artList = Db.find("SELECT buildid, name, year, childstyle, marks FROM art");

		        // 查询 build 表中的 buildid 和 buildname
		        List<Record> buildList = Db.find("SELECT id, name FROM build");
		        Map<Integer, String> buildNameMap = new HashMap<>();
		        for (Record build : buildList) {
		            buildNameMap.put(build.getInt("id"), build.getStr("name"));
		        }

		        // 按 buildid 分组
		        Map<Integer, List<Record>> groupedByBuildId = new HashMap<>();
		        for (Record art : artList) {
		            int buildid = art.getInt("buildid");

		            // 获取当前 buildid 的记录列表，如果不存在则创建一个新的列表
		            List<Record> buildRecords = groupedByBuildId.getOrDefault(buildid, new ArrayList<>());
		            buildRecords.add(art);
		            groupedByBuildId.put(buildid, buildRecords);
		        }

		        // 构建结果列表，每个 buildid 的记录作为一个数组
		        List<Map<String, Object>> resultList = new ArrayList<>();
		        for (Map.Entry<Integer, List<Record>> entry : groupedByBuildId.entrySet()) {
		            Map<String, Object> result = new HashMap<>();
		            int buildid = entry.getKey();
		            result.put("buildid", buildid);
		            result.put("name", buildNameMap.get(buildid)); // 加入 buildname
		            result.put("records", entry.getValue());
		            resultList.add(result);
		        }

		        // 返回结果
		        renderJson(IResult.ok(resultList));
		    } catch (Exception e) {
		        e.printStackTrace();
		        renderJson(IResult.fail("查询过程中发生错误。"));
		    }
		}
		
//		查询build对应的mxpath路径
		public void getMxpath(@Para("code") String code) {
	        // 根据 code 获取 mxpath
	        Record codeRecord = Db.findFirst("select mxpath from build where code = ?", code);
	        if (codeRecord == null) {
	            renderJson(IResult.fail("未找到对应的 mxpath"));
	            return;
	        }

	        String mxpath = codeRecord.getStr("mxpath");
	        renderJson(IResult.ok(mxpath));
	    }
		
		
//		通过areaid拿到当前id下的彩画分类并去重  20240725 update by FR13NDS 
		public void getArtStylesByAreaId() {
	        String areaId = getPara("areaid");
	        if (areaId == null) {
	            renderJson(IResult.fail("error"));
	            return;
	        }

	        // 定义四大类的名称
	        String[] artStyles = {"和玺彩画", "旋子彩画", "苏式彩画", "海墁彩画"};

	        // 创建一个列表来存储每种艺术风格及其数量
	        List<Record> resultList = new ArrayList<>();

	        // 遍历四大类，查询每种artStyle在指定areaid中的数量
	        for (String artStyle : artStyles) {
	            // 查询当前artStyle在指定areaid中的数量
	            Record artStyleCount = Db.findFirst("select COUNT(*) as count from art where areaid = ? and artstyle = ?", areaId, artStyle);

	            // 创建一个新的记录，将artStyle名称及其数量添加到结果列表中
	            Record result = new Record();
	            result.set("artStyle", artStyle);
	            result.set("count", artStyleCount.getLong("count"));

	            resultList.add(result);
	        }

	        // 返回结果列表
	        renderJson(IResult.ok(resultList));
	    } 






	





		
//		g.AddNode("一宫门","10","建筑");
//		g.AddNode("湖心亭","20","建筑");
//		
//		g.AddLink("0","10");
//		g.AddLink("10","20");
}
